<h3>Danh sách thành viên</h3>
<style type="text/css">
#pagination{
	padding-top:7px
}
#pagination a,
span.current{
	text-decoration:none;
	padding:0px 10px;
	border:1px solid #CCC;
	border-radius:3px;
	margin-right:3px;
}
span.current{
	color:#F00;
	font-weight:bold
}
td{
	border:1px solid #060;
	padding:3px 5px
}
tr.title td{
	height:22px;
	font-weight:bold;
	text-align:center;
	background:#060;
	color:#FFF
}
.red{
	color:#F00
}
</style>
<script type="text/javascript">
$(document).ready(function(){
    $(".del").click(function(){
		if(confirm("Bạn có muốn xóa không?")){
			$id = $(this).attr("name");
			$(this).parent().parent().fadeOut("slow");
			$.ajax({
				"url" : "modules/users/delajax.php",
				"type" : "post",
				"data" : "uid="+$id,
				"async" : false,
				success : function(result){
				}
			});	
		}
		return false;
	});
});
</script>
<div style="height:30px"></div>
<?php
require("libraries/users.php");
$users = new users();
$limit = 10; // 2 record trên 1 trang
if(isset($_GET['start'])){
	$start = $_GET['start'];
}else{
	$start = 0;
}
if(isset($_GET['pages'])){
	$totalpages = $_GET['pages'];
}else{
	$totalrecord = $users->totalrecord();
	$totalpages = ceil($totalrecord/$limit);
}
$listuser = $users->listuser($start,$limit);
?>
<table width="717" border="0">
  <tr class="title">
    <td width="37">Stt</td>
    <td width="169">Username</td>
    <td width="149">Full name</td>
    <td width="78">Gender</td>
    <td width="78">Level</td>
    <td width="197">Email</td>
    <td width="31">Edit</td>
    <td width="26">Del</td>
  </tr>
  <?php $stt = 1; ?>
  <?php foreach($listuser as $items){ ?>
  <tr>
    <td><?php echo $stt; ?></td>
    <td><?php echo $items['user_name']; ?></td>
    <td><?php echo $items['user_fullname']; ?></td>
    <td><?php if($items['user_gender'] == 1){ echo "Nam";}else{ echo "Nữ"; }?></td>
    <td><?php if($items['user_level'] == 1){ echo "<span class='red'>Admin</span>";}else{ echo "Member"; }?></td>
    <td><?php echo $items['user_email']; ?></td>
    <td><a href="<?php echo baseurl."admin/?page=user&act=edit&uid=".$items['user_id']; ?>">Sửa</a></td>
    <td><a class="del" name="<?php echo $items['user_id']; ?>" href="javascript:void(0)">Xóa</a></td>
  </tr>
  <?php $stt++; } ?>
</table>
<div id="pagination">
<?php
if($totalpages > 1){ // số trang phải từ 2 trang trở lên
	$current = ($start/$limit) + 1; // trang hiện hành
	if($current != 1){ // Nút prev
		$newstart = $start - $limit;
		echo "<a href='".baseurl."admin/?page=user&act=list&pages=$totalpages&start=$newstart'>Prev</a>";
	}
	for($i=1;$i<=$totalpages;$i++){
		$newstart = ($i - 1)*$limit;
		if($i == $current){
			echo "<span class='current'>".$i."</span>";
		}else{
			echo "<a href='".baseurl."admin/?page=user&act=list&pages=$totalpages&start=$newstart'>".$i."</a>";
		}
	}
	if($current != $totalpages){ // Nút next
		$newstart = $start + $limit;
		echo "<a href='".baseurl."admin/?page=user&act=list&pages=$totalpages&start=$newstart'>Next</a>";
	}
}
?>
</div>